package com.cincc.cinccimdemo.ui.me.favorite.viewholder;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import com.bumptech.glide.Glide;
import com.cincc.cinccimdemo.R;
import com.cincc.cinccimdemo.ui.conversation.mm.PreviewActivity;
import com.cincc.im.model.CollectModel;
import com.cincc.im.util.Base64Util;

import org.json.JSONObject;

public class FavVideoContentViewHolder extends FavContentViewHolder {
    ImageView imageView;

    public FavVideoContentViewHolder(@NonNull View itemView) {
        super(itemView);
        bindViews(itemView);
    }

    private void bindViews(View itemView) {
        imageView = itemView.findViewById(R.id.favImageContentImageView);
    }

    @Override
    public void bind(Activity context, CollectModel item) {
        super.bind(context, item);
        try {
            String data = Base64Util.decodeToString(item.messageContent);
            JSONObject jsonObject = new JSONObject(data);
            String thumb = jsonObject.getString("thumb");
            Glide.with(itemView)
                    .load(thumb).into(imageView);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onClick() {
        PreviewActivity.previewImage(mContext, favoriteItem);
    }
}
